"""
 ** ATTENTION **
 This code was automatically generated from the file:
 _moc_cst.yaml 

 Do not modify it directly. Modify the configuration file and
 run the generator again.
 ** ** *** ** **

@license: License: LGPL
@copyright: (c) 2009, dogsing.cn
@author: ant-man(Bin Zhao)
"""


import sys


class CstNode(object):
    """ Abstract base class for CST nodes.
    """
    
    def accept(self, visitor):
        """
        User Visitor pattern to issue some kind of action,
        that binding with the specified type of node
        
        visitor : instance of NodeVisistor or its subclass 
        """
        return visitor.visit(self)
        
class Newdict(CstNode):
    def __init__(self, num, ret, coord=None):
        self.num = num
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "newdict %s %s" % (self.ret, self.num)

class Slice(CstNode):
    def __init__(self, src, ret, coord=None):
        self.src = src
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "slice %s %s" % (self.ret, self.src)

class End(CstNode):
    def __init__(self, coord=None):
        self.coord = coord

    def __str__(self):
        return "end"

class UnaryOp(CstNode):
    def __init__(self, op, right, ret, coord=None):
        self.op = op
        self.right = right
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "%s = %s %s" % (self.ret, self.op, self.right)

class Setret(CstNode):
    def __init__(self, src, coord=None):
        self.src = src
        self.coord = coord

    def __str__(self):
        return "setret %s" % (self.src)

class Label(CstNode):
    def __init__(self, label, lineno, coord=None):
        self.label = label
        self.lineno = lineno
        self.coord = coord

    def __str__(self):
        return "L%s:" % (self.label)

class Begin(CstNode):
    def __init__(self, coord=None):
        self.coord = coord

    def __str__(self):
        return "begin"

class Param(CstNode):
    def __init__(self, val, coord=None):
        self.val = val
        self.coord = coord

    def __str__(self):
        return "param %s" % (self.val)

class Getret(CstNode):
    def __init__(self, ret, coord=None):
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "getret %s" % (self.ret)

class Objref(CstNode):
    def __init__(self, obj, field, ret, coord=None):
        self.obj = obj
        self.field = field
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "objref %s %s.%s" % (self.ret, self.obj, self.field)

class CallableDef(CstNode):
    def __init__(self, params, body, ret, coord=None):
        self.params = params
        self.body = body
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "Callable %s" % self.ret

class Call(CstNode):
    def __init__(self, name, param_num, coord=None):
        self.name = name
        self.param_num = param_num
        self.coord = coord

    def __str__(self):
        return "call %s, %d" % (self.name, self.param_num)

class Listitem(CstNode):
    def __init__(self, val, coord=None):
        self.val = val
        self.coord = coord

    def __str__(self):
        return "listitem %s" % (self.val)

class Range(CstNode):
    def __init__(self, low, high, coord=None):
        self.low = low
        self.high = high
        self.coord = coord

    def __str__(self):
        return "range %s %s" % (self.low, self.high)

class Collref(CstNode):
    def __init__(self, coll, subscript, coord=None):
        self.coll = coll
        self.subscript = subscript
        self.coord = coord

    def __str__(self):
        return "Collref %s %s" % (self.coll, self.subscript)

class IfTrue(CstNode):
    def __init__(self, test, goto, coord=None):
        self.test = test
        self.goto = goto
        self.coord = coord

    def __str__(self):
        return "if %s %s" % (self.test, self.goto)

class Leaveenv(CstNode):
    def __init__(self, coord=None):
        self.coord = coord

    def __str__(self):
        return "leavenv"

class AssignOp(CstNode):
    def __init__(self, src, target, coord=None):
        self.src = src
        self.target = target
        self.coord = coord

    def __str__(self):
        return "%s = %s" % (self.target, self.src)

class Adddictkey(CstNode):
    def __init__(self, key, target, coord=None):
        self.key = key
        self.target = target
        self.coord = coord

    def __str__(self):
        return "adddictkey %s %s" % (self.key, self.target)

class Goto(CstNode):
    def __init__(self, label, coord=None):
        self.label = label
        self.coord = coord

    def __str__(self):
        return "goto %s" % (self.label)

class Newlist(CstNode):
    def __init__(self, num, ret, coord=None):
        self.num = num
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "newlist %s %s" % (self.ret, self.num)

class Dictitem(CstNode):
    def __init__(self, key, val, coord=None):
        self.key = key
        self.val = val
        self.coord = coord

    def __str__(self):
        return "dictitem %s %s" % (self.key, self.val)

class IfFalse(CstNode):
    def __init__(self, test, goto, coord=None):
        self.test = test
        self.goto = goto
        self.coord = coord

    def __str__(self):
        return "iffalse %s %s" % (self.test, self.goto)

class BinaryOp(CstNode):
    def __init__(self, op, left, right, ret, coord=None):
        self.op = op
        self.left = left
        self.right = right
        self.ret = ret
        self.coord = coord

    def __str__(self):
        return "%s = %s %s %s" % (self.ret, self.left, self.op, self.right) if self.ret else "%s %s %s" % (self.left, self.op, self.right) 

class Enterenv(CstNode):
    def __init__(self, coord=None):
        self.coord = coord

    def __str__(self):
        return "enterenv"

class Objassign(CstNode):
    def __init__(self, src, obj, field, coord=None):
        self.src = src
        self.obj = obj
        self.field = field
        self.coord = coord

    def __str__(self):
        return "objassign %s %s.%s" % (self.src, self.obj, self.field)

